# Maintainer: winbo-yml-exe <winbo.yml@proton.me>
# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-raspberry-pi5
pkgver=1
pkgrel=0
pkgdesc="Raspberry Pi 5"
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="postmarketos-base raspberrypi-bootloader linux-rpi"
makedepends="devicepkg-dev"
subpackages="
	$pkgname-nonfree-firmware:nonfree_firmware
	$pkgname-openrc
	$pkgname-plasma-bigscreen:plasma_bigscreen
	"
source="
	deviceinfo
	modules-initfs
	usercfg.txt
	cmdline.txt
	95-vchiq-permissions.rules
	enforce-platform.sh
	"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
	install -Dm644 "$srcdir"/usercfg.txt "$pkgdir"/boot/usercfg.txt
	install -Dm644 "$srcdir"/cmdline.txt "$pkgdir"/boot/cmdline.txt
	install -Dm644 "$srcdir"/95-vchiq-permissions.rules \
		"$pkgdir"/etc/udev/rules.d/95-vchiq-permissions.rules
	install -Dm755 "$srcdir"/enforce-platform.sh -t "$pkgdir"/etc/profile.d/
}

nonfree_firmware() {
	pkgdesc="WiFi/Bluetooth firmware"
	depends="linux-firmware-brcm"
	mkdir "$subpkgdir"
}

openrc() {
	install_if="$pkgname=$pkgver-r$pkgrel openrc"
	install="$subpkgname.post-install $subpkgname.post-upgrade"

	mkdir -p "$subpkgdir"
}

plasma_bigscreen() {
	pkgdesc="$pkgdesc (Plasma Bigscreen)"
	install_if="$pkgname plasma-bigscreen"

	amove etc/profile.d
}


sha512sums="
52a562c316e540a5f746f566f51cf6cc6455932c747606543c8a40b067b6add50348b9342b35d96ff0b0d0955bcabbe9b1d07c30a81ec82f118c39c1a5d08034  deviceinfo
e3515cf9f41807917eac1f7663e0131bd18783824facf15f2bb0381635bf6d9a0c334f3786b6fb76d01469de6449878c871f8b747f45e9e3cee77699905cf319  modules-initfs
4e832421e47dd0faf443a7a949aae83cc6d4a80fd816df5c6d9d72ac4ae23f803863b9b63903a14b18ae585e6abc5c8703376a003967b74dc30040dc544aa2e9  usercfg.txt
ae3de0b8fec07d3a283dc3c06bf8678eec1e65c9faf0b7f4fdc9fb92751e324d1f8e2fb224dbbf561b7e5a6fb34769bfa1657858375f74b101a130d78e0737e2  cmdline.txt
7e5505cb07d5b4a81bd28443d508336b5c547356538f1c06f91ed93ad0d7d456d4f74f1d24df5a2e08c17e74f0a66607352ac4874e967e9a91dfec9522d2d58d  95-vchiq-permissions.rules
5ebdd05414792b82073a6453517c19458863809cdfb25e7d8857030c1feb69cbebc02c5309e6a14373125d83e5e673a20f2006520a34148af17219fb1863dd95  enforce-platform.sh
"
